package com.ldzy.service.serviceIpmI;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ldzy.dao.ShoppingMapper;
import com.ldzy.pojo.Shopping;
import com.ldzy.service.IShoppingService;
import com.ldzy.utilts.RespUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class IShoppingServiceIpmI extends ServiceImpl<ShoppingMapper, Shopping> implements IShoppingService {
    @Resource
    ShoppingMapper shoppingMapper;

    @Override
    public RespUtil findByUser_Cake_id(Shopping shopping) {
        if (shoppingMapper.findByUser_Cake_id(shopping)!=null)
            return RespUtil.success(shoppingMapper.findByUser_Cake_id(shopping));
        return  RespUtil.error();
    }

    @Override
    public Boolean updateNumber(Shopping shopping) {
        if (shoppingMapper.updateNumber(shopping)!=0)
            return  true;
        return  false;
    }

    @Override
    public Boolean isFindBy(Shopping shopping) {
        if (shoppingMapper.findByUser_Cake_id(shopping)!=null)
            return  true;
        return  false;
    }

    @Override
    public RespUtil findShopping(Shopping shopping) {
     return  RespUtil.success(shoppingMapper.findShopping(shopping));
    }

    @Override
    public RespUtil deleteOrder(Shopping shopping) {
        if (shoppingMapper.deleteOrder(shopping)!=0)
            return  RespUtil.success("删除成功!!");
        return RespUtil.error("删除失败!!");
    }

    @Override
    public RespUtil updateNumberChange(Shopping shopping) {
       if (shoppingMapper.updateNumberChange(shopping)!=0)
           return RespUtil.success("操作成功！！");
       return  RespUtil.error("操作失败！！");
    }

    @Override
    public Shopping shopping(Shopping shopping) {
        return  shoppingMapper.shopping(shopping);
    }
}
